Component({
  properties: {
    // 04zhuanhuan | switch_female-copy | switch_male-copy | iconfontzhizuobiaozhun023116 | weishoucang | shengciben2 | shoucang-yishoucang | yidongduan_yishoucang | weishoucang1 | jiarushengciben | tubiaozhizuomoban-01 | sandian | sandian1 | sandian2 | pinglun3 | pinglun | pinglun1 | pinglun2 | comment | fabu2 | paperplane | fabu2-copy | fabu-copy | fabu-copy-copy | fabu-copy-copy-copy | fabu | fabu1 | shanchu | shanchu1 | dianzan_kuai | dianzan_kuai-copy | dianzan | dianzan1 | dianzan2 | dianzan3 | sousuo | sousuo1 | xiangxia | arrowRight-copy | xiajiantou | youjiantou | zuojiantou | jiantou | jiantou1 | zuojiantou1 | bianji | bianji1 | bianji2 | bianji3 | shengciben1 | shengciben | gexingqianming | dating-gexingqianming | gexingqianming1 | dating-gexingqianming-copy | mima | yule | ybbindex | confused | tubiaozhizuomoban | shoucang | mima1 | fanyi | shoucang1 | tubiao-fanyi | wode | xihuan | nuli | wode-copy | ybbindex-copy | tubiao-fanyi-copy
    name: {
      type: String,
    },
    // string | string[]
    color: {
      type: null,
      observer: function(color) {
        this.setData({
          colors: this.fixColor(),
          isStr: typeof color === 'string',
        });
      }
    },
    size: {
      type: Number,
      value: 18,
      observer: function(size) {
        this.setData({
          svgSize: size,
        });
      },
    },
  },
  data: {
    colors: '',
    svgSize: 18,
    quot: '"',
    isStr: true,
  },
  methods: {
    fixColor: function() {
      var color = this.data.color;
      var hex2rgb = this.hex2rgb;

      if (typeof color === 'string') {
        return color.indexOf('#') === 0 ? hex2rgb(color) : color;
      }

      return color.map(function (item) {
        return item.indexOf('#') === 0 ? hex2rgb(item) : item;
      });
    },
    hex2rgb: function(hex) {
      var rgb = [];

      hex = hex.substr(1);

      if (hex.length === 3) {
        hex = hex.replace(/(.)/g, '$1$1');
      }

      hex.replace(/../g, function(color) {
        rgb.push(parseInt(color, 0x10));
        return color;
      });

      return 'rgb(' + rgb.join(',') + ')';
    }
  }
});
